package org.spring.springboot.server.Impl;

import org.spring.springboot.dao.ExitlistDao;
import org.spring.springboot.entity.Exitlist;
import org.spring.springboot.exception.APIException;
import org.spring.springboot.po.ExitlistPO;
import org.spring.springboot.server.ExitlistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ExitlistServiceImpl implements ExitlistService {
    @Autowired
    private ExitlistDao exitlistDao;

    @Override
    public void addExitList(ExitlistPO el) {
//        String carNumber1 = el.getCarNumber();
//        String carNumber2= "([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]" +
//                "{1}(([A-HJ-Z]{1}[A-HJ-NP-Z0-9]{5})|([A-HJ-Z]{1}(([DF]{1}[A-HJ-NP-Z0-9]{1}[0-9]{4})|([0-9]{5}[DF]" +
//                "{1})))|([A-HJ-Z]{1}[A-D0-9]{1}[0-9]{3}警)))|([0-9]{6}使)|((([沪粤川云桂鄂陕蒙藏黑辽渝]{1}A)|鲁B|闽D|蒙E|蒙H)[0-9]{4}领)" +
//                "|(WJ[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼·•]{1}[0-9]{4}[TDSHBXJ0-9]{1})" +
//                "|([VKHBSLJNGCE]{1}[A-DJ-PR-TVY]{1}[0-9]{5})";
//        boolean flag = carNumber1.matches(carNumber2);
//        if (flag == true){
//            exitlistDao.insert(el);
//        }
//        else {
//            throw new APIException("车牌号输入错误");
//        }
        exitlistDao.insert(el);
    }

    @Override
    public List<Map<String, Object>> selectByExitlist() {
        return exitlistDao.selectByExitlist();
    }

    @Override
    public List<Map<String, Object>> selectById() {
        return exitlistDao.selectById();
    }

    @Override
    public List<Map<String, Object>> selectOpinion01() {
        return exitlistDao.selectByOpinion01();
    }

    @Override
    public List<Map<String, Object>> selectOpinionNull() {
        return exitlistDao.selectByOpinionNull();
    }

    @Override
    public void updateApproveOpinion(String approver,String approveTel,Integer approveOpinion,String remark,Integer id) {
        exitlistDao.approvemanage(approver, approveTel, approveOpinion, remark, id);
    }

    @Override
    public Integer selectNumberNull() {
        return exitlistDao.selectNumberNull();
    }

    @Override
    public Integer selectNumber01() {
        return exitlistDao.selectNumber01();
    }

    @Override
    public void deleteExitUser(Integer id) {
        exitlistDao.delete(id);
    }

    @Override
    public void updateExitUser(Integer id, String agent, String agent_tel, String department, String approver, String approve_tel) {
         exitlistDao.update(id, agent, agent_tel, department, approver, approve_tel);
    }

}
